﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace MainPath
{
    public static class MyPath
    {
        public static string DirTemp = string.Empty;
        public static string DirSolution = string.Empty;
        public static string HtmlTemplete = string.Empty;
        public static string ScriptTemplete = string.Empty;
        public static string LinkTemplete = string.Empty;
        static MyPath() 
        {
            DirTemp = Application.StartupPath + "\\Temp\\";
            if (!Directory.Exists(DirTemp)) 
            {
                Directory.CreateDirectory(DirTemp);
            }
            DirSolution = Application.StartupPath + "\\Solution\\";
            if (!Directory.Exists(DirSolution)) 
            {
                Directory.CreateDirectory(DirSolution);
            }
            HtmlTemplete = Application.StartupPath + "\\templete.html";
            ScriptTemplete = Application.StartupPath + "\\script.html";
            LinkTemplete = Application.StartupPath + "\\link.html";
        }

        public static string GetNewImage(string ext)
        {
            string filepath = DirTemp + DateTime.Now.Ticks.ToString() + ext;
            return filepath;
        }

        public static string ConvertPath(string header,string solutionname)
        {
            string tem = header.Replace("${root}","/"+solutionname);
            tem = tem.Replace("${rootcomponent}", "/" + solutionname + "/ComponentSource");
            return tem;
        }

        public static string GetSolutionZip(string file)
        {
            string filename = Path.GetFileName(file);
            return DirSolution + filename;
        }


        public static string GetComponentZip(string solutionname, string file)
        {
            string filename = Path.GetFileName(file);
            string tem = DirSolution + solutionname + "\\ComponentSource\\";
            if (!Directory.Exists(tem)) 
            {
                Directory.CreateDirectory(tem);
            }
            return tem+ filename;
        }

        public static string GetZipForDirPath(string FilePath)
        {
            string dir = Path.GetDirectoryName(FilePath) + "\\";
            string filename = Path.GetFileName(FilePath);
            string ext = Path.GetExtension(FilePath);
            filename = filename.Replace(ext, "");
            return dir + filename + "\\";
        }
    }
}
